home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / btrieve / bfile.arc / PAGEOP.PAS < prev    next >
Pascal/Delphi Source File  |  1986-06-16  |  1KB  |  43 lines

  1. PROGRAM OptimumPageSize;
  2.  
  3.   TYPE
  4.     PageInfo =
  5.       RECORD
  6.         Bytes   : Integer;
  7.         NumRecs : Integer;
  8.         Unused  : Integer
  9.       END;
  10.  
  11.   VAR
  12.     Pages      : ARRAY [1 .. 8] OF PageInfo;
  13.     Best       : Byte;
  14.     NumDupKeys : Integer;
  15.     Loc        : Integer;
  16.     RecByteLen : Integer;
  17.  
  18.   BEGIN { OptimumPageSize }
  19.     FillChar (Pages, SizeOf (Pages), 0);
  20.     Write ('Enter record length in bytes   : ');
  21.     ReadLn (RecByteLen);
  22.     Write ('Enter number of duplicate keys : ');
  23.     ReadLn (NumDupKeys);
  24.     FOR Loc := 1 TO 8 DO
  25.       WITH Pages[Loc] DO
  26.         BEGIN
  27.           Bytes   := 512 * Loc;
  28.           NumRecs := (Bytes - 6) DIV (RecByteLen + 8 * NumDupKeys);
  29.           Unused  := Bytes - 6 - (NumRecs * (RecByteLen + 8 * NumDupKeys) )
  30.         END;
  31.     Best := 1;
  32.     FOR Loc := 1 TO 7 DO
  33.       IF Pages[Best].Unused > Pages[Loc + 1].Unused THEN
  34.         Best := Loc + 1;
  35.     WriteLn;
  36.     WITH Pages[Best] DO
  37.       WriteLn ('Best fit is ', Bytes, ' with ', NumRecs, ' records and only ', Unused, ' unused bytes');
  38.     WriteLn;
  39.     FOR Loc := 1 TO 8 DO
  40.       WITH Pages[Loc] DO
  41.         WriteLn ('Page ', Bytes:4, '  Records ', NumRecs:4, ' unused bytes ', Unused:4)
  42.   END   { OptimumPageSize }.
  43.